package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.ZhwyShops;
import com.ruoyi.system.mapper.ZhwyShopsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ZhwyRentalcontractMapper;
import com.ruoyi.system.domain.ZhwyRentalcontract;
import com.ruoyi.system.service.IZhwyRentalcontractService;

/**
 * 租售合同管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@Service
public class ZhwyRentalcontractServiceImpl implements IZhwyRentalcontractService 
{
    @Autowired
    private ZhwyRentalcontractMapper zhwyRentalcontractMapper;
    @Autowired
    private ZhwyShopsMapper zhwyShopsMapper;

    /**
     * 查询租售合同管理
     * 
     * @param id 租售合同管理主键
     * @return 租售合同管理
     */
    @Override
    public ZhwyRentalcontract selectZhwyRentalcontractById(Long id)
    {
        return zhwyRentalcontractMapper.selectZhwyRentalcontractById(id);
    }

    /**
     * 查询租售合同管理列表
     * 
     * @param zhwyRentalcontract 租售合同管理
     * @return 租售合同管理
     */
    @Override
    public List<ZhwyRentalcontract> selectZhwyRentalcontractList(ZhwyRentalcontract zhwyRentalcontract) {
        List<ZhwyRentalcontract> list = zhwyRentalcontractMapper.selectZhwyRentalcontractList(zhwyRentalcontract);
        for(ZhwyRentalcontract li : list){
            ZhwyShops zhwyShops = zhwyShopsMapper.selectZhwyShopsById(li.getShopsId());
            li.setShopCode(zhwyShops.getCode());
        }
        return list;
    }
//
    /**
     * 新增租售合同管理
     * 
     * @param zhwyRentalcontract 租售合同管理
     * @return 结果
     */
    @Override
    public int insertZhwyRentalcontract(ZhwyRentalcontract zhwyRentalcontract)
    {
        return zhwyRentalcontractMapper.insertZhwyRentalcontract(zhwyRentalcontract);
    }

    /**
     * 修改租售合同管理
     * 
     * @param zhwyRentalcontract 租售合同管理
     * @return 结果
     */
    @Override
    public int updateZhwyRentalcontract(ZhwyRentalcontract zhwyRentalcontract)
    {
        return zhwyRentalcontractMapper.updateZhwyRentalcontract(zhwyRentalcontract);
    }

    /**
     * 批量删除租售合同管理
     * 
     * @param ids 需要删除的租售合同管理主键
     * @return 结果
     */
    @Override
    public int deleteZhwyRentalcontractByIds(Long[] ids)
    {
        return zhwyRentalcontractMapper.deleteZhwyRentalcontractByIds(ids);
    }

    /**
     * 删除租售合同管理信息
     * 
     * @param id 租售合同管理主键
     * @return 结果
     */
    @Override
    public int deleteZhwyRentalcontractById(Long id)
    {
        return zhwyRentalcontractMapper.deleteZhwyRentalcontractById(id);
    }
}
